﻿using System.IO;
using HardMock;
using Xunit;

namespace AcceptanceTests
{
    public class ControlCouplingFeature
    {
        [Fact]
        public void Should_simulate_control_coupling()
        {
            var hardmock = new StateFullHardMock();
            _MUODate muoDate = new MUODate();

            var recorder = hardmock.BuildRecorderOver(muoDate);
            SimulateControlCoupling(recorder);

            using (var stream = new MemoryStream())
            {
                recorder.Snapshot(stream);

                var replayer = hardmock.BuildMockFrom<_MUODate>(stream);

                SimulateControlCoupling(replayer);
            }
        }

        private static void SimulateControlCoupling(_MUODate recorder)
        {
            Assert.False(recorder.ControlCoupling());
            recorder.IsActivated = false;
            Assert.False(recorder.ControlCoupling());

            recorder.IsActivated = true;
            Assert.True(recorder.ControlCoupling());
        }
    }
}
